package com.bt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bt.mapper.DtsGoodsSpecificationMapper;
import com.bt.pojo.DtsGoodsSpecification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author wbt
 * @version v1.0
 * @project shop_manage
 * @data 2022/9/23 15:44
 **/
@Service
public class DtsGoodsSpecificationServiceImpl implements DtsGoodsSpecificationService {
    @Autowired
    private DtsGoodsSpecificationMapper dtsGoodsSpecificationMapper;
    @Override
    public List<DtsGoodsSpecification> findDtsGoodsSpecificationByGoodsId(Integer id) {
        return dtsGoodsSpecificationMapper.selectList(new QueryWrapper<DtsGoodsSpecification>().eq(id!=null?true:false,"goods_id",id));
    }

    @Override
    public void updateGoodsSpecification(List<DtsGoodsSpecification> specifications, Integer id) {
        dtsGoodsSpecificationMapper.delete(new QueryWrapper<DtsGoodsSpecification>().eq("goods_id",id));
        dtsGoodsSpecificationMapper.insertBatch(specifications);
    }
    @Override
    public void insertGoodsSpecification(List<DtsGoodsSpecification> specifications) {
        dtsGoodsSpecificationMapper.insertBatch(specifications);
    }

    @Override
    public void deleteGoodsSpecificationByGoodsId(Integer id) {
        dtsGoodsSpecificationMapper.delete(new QueryWrapper<DtsGoodsSpecification>().eq("goods_id",id));
    }
}
